<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Quanlydonhang extends MY_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 Thu
	 */
	 function __construct()
    {
        parent::__construct();	
		$this->data['tieude']="Quản Lý Đơn Đặt Hàng";
		$this->loadadmin();
	}
	public function index()
	{
		$this->load->model('Dondathang_model');	
		$this->data=$this->Dondathang_model->getresult_index();
		$this->load->view('dondathang/dondathang',$this->data);
		$this->load->view('layout/footer');
	}
	public function chitiet($maddh)
	{
		$this->load->model('Dondathang_model');
		$this->data['dondathang']=$this->Dondathang_model->getdondathang($maddh);
		$this->data['chitietdonhangs']=$this->Dondathang_model->getresult_chitietdonhang($maddh);
		$this->data['thongtinthanhtoan']=$this->Dondathang_model->getthongtinthanhtoan($maddh);
		$this->load->view('dondathang/chitietdondathang',$this->data);
		$this->load->view('layout/footer');
	}
	public function giao($maddh)
	{
		$this->load->model('Dondathang_model');
		$this->Dondathang_model->giao($maddh);
		$dt= $this->input->get();
		if(empty($dt['page']))
		{
			$dt['page']=1;
		}
		if(!empty($dt['tt']))	
		redirect("/Quanlydonhang/index/?tt={$dt['tt']}&page={$dt['page']}", 'refresh');
		else 
    	redirect("/Quanlydonhang/index/?page={$dt['page']}", 'refresh');
	}
	public function xoa($maddh)
	{
		$this->load->model('Dondathang_model');
		$this->Dondathang_model->xoa($maddh);
		$dt= $this->input->get();
		if(empty($dt['page']))
		{
			$dt['page']=1;
		}
		if(!empty($dt['tt']))	
		redirect("/Quanlydonhang/index/?tt={$dt['tt']}&page={$dt['page']}", 'refresh');
		else 
    	redirect("/Quanlydonhang/index/?page={$dt['page']}", 'refresh');
	}

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */